﻿/*添加店铺*/
function addShop() {
    $("#showShopConfirm").data("old", $("#showShopConfirm").html());
    $("#loading").show();
    $("#showShopConfirm").hide();    
    $.blockUI({ message: $('#shopConBar'), css: { border: '0px', padding: '0px' }, overlayCSS: { backgroundColor: '#fff', opacity: '0.8'} });
    $.getJSON("/do/addShop.aspx", { type: "ajax", url: $("#txtShopId").val(), m: Math.random() }, function(json1) {
        $("#loading").hide();
        $("#showShopConfirm").show();
        if (json1.title == "null") {
            $("#showShopConfirm").html("<p>" + json1.seller + "</p><input type=\"button\" value=\"返回\" onclick=\"clearUi()\" class=\"btn\" />");
        } else {
            if (json1.flag == "true") {
                $("#showShopConfirm").html("<p>该店铺已添加过，不可重复添加！</p><input type=\"button\" value=\"返回\" onclick=\"clearUi()\" class=\"btn\" />");
            } else {
                $("#shopIcon").attr("src", json1.icon);
                $("#hidNick").attr("value", json1.seller);
                $("#shopTitle").html(json1.title);
                $("#shopCreated").html(json1.created);
                $("#seller").html(json1.seller);
            }
        }
    });
    return false;
}
function clearUi() {
    $.unblockUI();
    $("#showShopConfirm").html($("#showShopConfirm").data("old"));
}

/*日期选择*/
function showDatePicker(obj) {
    $(".datePicker").show();
    $(".datePicker").data("old",$(".viewDate").html());
    $(".viewDate").html("<span>自定义统计时间</span>");
}
function appDateQuery() {
    
}
function clearDatePicker() {
    $(".datePicker").hide();
    $(".viewDate").html($(".datePicker").data("old"))
}
function insertShopData() {

}
function gotoSelect(oSelect) {
    var url = location.href;
    url = url.substring(0, url.indexOf("?"))
    url = url + "?nick=" + oSelect.options[oSelect.selectedIndex].value;
    this.location.href = url;
}
function closeBtn(f) {
    var obj = f.getElementsByTagName("input");
    for (var i = 0; i < obj.length; i++) {
        if (obj[i].type == "submit") {
            obj[i].value = "递交中...";
            obj[i].disabled = true;
        }
    }
}
function scrollInfo() {
    $(".scrollText ul").fadeOut("fast");
    $(".scrollText ul").fadeIn("fast");
    $(".scrollText ul").append($(".scrollText ul li:first"));
}

$(document).ready(function() {
    if ($("#msgNews").length > 0) {
        var outHtml;
        outHtml = "";
        $.get("/news.xml", function(data) {
            $(data).find("item").each(function() {
                var item = $(this);
                var title = item.find("title").text();
                var url = item.find("url").text();
                outHtml += "<li><a href=\"" + url + "\">" + title + "</a></li>"
            });
            outHtml = "<h3>公告：</h3><div class=\"scrollText\"><ul>" + outHtml + "</ul></div>";
            $("#msgNews").html(outHtml);
            showinfo = setInterval("scrollInfo()", 4000);
        });
    }
});

//订购
function getBuySign() {
    var pd, sdate, pr, m;
    pd = $("#softPostData").val();
    sdate = $("#softBeginDate").val();
    pr = $("input:checked").val();
   
    m = $("#userDate").val();

    r = Math.random();
    $("#showMsg").html("数据处理中....");
    $.blockUI({ message: $('#showMsg'), css: { border: '0px', padding: '0px'} });
    $.getJSON("/do/getSign.aspx", { postData: pd, start: sdate, price: pr, month: m, mr: r }, function(json) {

        //表单项赋值
        $("#rentAmount").val(json.rentAmount);
        $("#amount").val(json.amount);
        $("#resourceAmount").val(json.resourceAmount);
        $("#gmtEnd").val(json.gmtEnd);
        $("#postData").val(json.postData);
        $("#gmtStart").val(json.gmtStart);
        $("#signature").val(json.signature);
        $.unblockUI();
        $("#buyForm").target = "_top";
        $("#buyForm").submit();
    });
    return false;
}